using System;

namespace Microsoft.WowAddonStudio.Lua.RuntimeService.WowBench
{
	/// <summary>
	/// Represents event data for IOutputWriter events.
	/// </summary>
	public class OutputWriterEventArgs : EventArgs
	{
		/// <summary>
		/// Gets the current buffer position.
		/// </summary>
		public int BufferPosition { get; set; }

		/// <summary>
		/// Gets the current text to be processed.
		/// </summary>
		public string Text { get; set; }
	
		/// <summary>
		/// Initializes a new instance of the <see cref="OutputWriterEventArgs"/> class.
		/// </summary>
		/// <param name="text">The text in the buffer.</param>
		public OutputWriterEventArgs(string text):this(text, -1)
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="OutputWriterEventArgs"/> class.
		/// </summary>
		/// <param name="text">The text in the buffer.</param>
		/// <param name="position">The text position in the buffer.</param>
		public OutputWriterEventArgs(string text, int position)
		{
			Text = text;
			BufferPosition = position;
		}

		/// <summary>
		/// Returns a <see cref="System.String"/> that 
		/// represents the current <see cref="OutputWriterEventArgs"/>.
		/// </summary>
		/// <returns></returns>
		public override string ToString()
		{
			return String.Concat("OutputWriterEventArgs: ", Text);
		}
	}

	/// <summary>
	/// Represents event data for IOutputWriter OnWriteCommited event.
	/// </summary>
	public sealed class OnBeforeWriteEventArgs : OutputWriterEventArgs
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="OnBeforeWriteEventArgs"/> class.
		/// </summary>
		/// <param name="text">The text in the buffer.</param>
		public OnBeforeWriteEventArgs(string text)
			: this(text, -1)
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="OnBeforeWriteEventArgs"/> class.
		/// </summary>
		/// <param name="text">The text in the buffer.</param>
		/// <param name="position">The text position in the buffer.</param>
		public OnBeforeWriteEventArgs(string text, int position)
			: base(text, position)
		{
			Cancel = false;
		}

		/// <summary>
		/// Gets or sets a value indicating whether current text 
		/// in buffer should be discarded.
		/// </summary>
		public bool Cancel{get; set;}
	}
}